﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Web.Configuration;


namespace DTO
{
    public class WebAppSection : ConfigurationSection
    {
        [ConfigurationProperty("defaultConnectionStringName", DefaultValue = "WebAppSqlServer")]
        public string DefaultConnectionStringName
        {
            get { return (string)base["defaultConnectionStringName"]; }
            set {  base["defaultConnectionStringName"] = value; }
        }

        public string ConnectionString
        {
            get { return WebConfigurationManager.ConnectionStrings[DefaultConnectionStringName].ConnectionString; }
        }
        [ConfigurationProperty("defaultCacheDuration", DefaultValue = "600")]
        public int DefaultCacheDuration
        {
            get { return (int)base["defaultCacheDuration"]; }
            set { base["defaultCacheDuration"] = value; }
        }

        [ConfigurationProperty("contactForm", IsRequired = true)]
        public ContactFormElement ContactForm
        {
            get { return (ContactFormElement)base["contactForm"]; }
        }

        [ConfigurationProperty("articles", IsRequired = true)]
        public ArticlesElement Articles
        {
            get { return (ArticlesElement)base["articles"]; }
        }

        [ConfigurationProperty("store", IsRequired = true)]
        public StoreElement Store
        {
            get { return (StoreElement)base["store"]; }
        }

        [ConfigurationProperty("branch", IsRequired = true)]
        public BranchElement Branch
        {
            get { return (BranchElement)base["branch"]; }
        }

        [ConfigurationProperty("page", IsRequired = true)]
        public PageElement Page
        {
            get { return (PageElement)base["page"]; }
        }

        [ConfigurationProperty("setting", IsRequired = true)]
        public SettingElement Setting
        {
            get { return (SettingElement)base["setting"]; }
        }

        [ConfigurationProperty("media", IsRequired = true)]
        public MediaElement Media
        {
            get { return (MediaElement)base["media"]; }
        }

        [ConfigurationProperty("faq", IsRequired = true)]
        public FaqElement Faq
        {
            get { return (FaqElement)base["faq"]; }
        }

    }

    public class ContactFormElement : ConfigurationElement
    {
        [ConfigurationProperty("mailSubject", DefaultValue = "Mail from Phuochoa.vn : {0}")]
        public string MailSubject
        {
            get { return (string)base["mailSubject"]; }
            set { base["mailSubject"] = value; }
        }

        [ConfigurationProperty("mailTo", IsRequired = true)]
        public string MailTo
        {
            get { return (string)base["mailTo"]; }
            set { base["mailTo"] = value; }
        }

        [ConfigurationProperty("mailCC")]
        public string MailCC
        {
            get { return (string)base["mailCC"]; }
            set { base["mailCC"] = value; }
        }
    }

    public class ArticlesElement : ConfigurationElement
    {
        [ConfigurationProperty("pageSize", DefaultValue = "10")]
        public int PageSize
        {
            get { return (int)base["pageSize"]; }
            set { base["pageSize"] = value; }
        }

        [ConfigurationProperty("rssItems", DefaultValue = "5")]
        public int RssItems
        {
            get { return (int)base["rssItems"]; }
            set { base["rssItems"] = value; }
        }

        [ConfigurationProperty("enableCaching", DefaultValue = "true")]
        public bool EnableCaching
        {
            get { return (bool)base["enableCaching"]; }
            set { base["enableCaching"] = value; }
        }

        [ConfigurationProperty("cacheDuration")]
        public int CacheDuration
        {
            get
            {
                return (int)base["cacheDuration"];
            }
            set { base["cacheDuration"] = value; }
        }

    }

    public class StoreElement : ConfigurationElement
    {
        [ConfigurationProperty("pageSize", DefaultValue = "10")]
        public int PageSize
        {
            get { return (int)base["pageSize"]; }
            set { base["pageSize"] = value; }
        }

        [ConfigurationProperty("rssItems", DefaultValue = "5")]
        public int RssItems
        {
            get { return (int)base["rssItems"]; }
            set { base["rssItems"] = value; }
        }

        [ConfigurationProperty("enableCaching", DefaultValue = "true")]
        public bool EnableCaching
        {
            get { return (bool)base["enableCaching"]; }
            set { base["enableCaching"] = value; }
        }

        [ConfigurationProperty("cacheDuration")]
        public int CacheDuration
        {
            get
            {
                return (int)base["cacheDuration"];
            }
            set { base["cacheDuration"] = value; }
        }

        [ConfigurationProperty("nProductisNew")]
        public int NProductisNew
        {
            get { return (int)base["nProductisNew"]; }
            set { base["nProductisNew"] = value; }
        }

        [ConfigurationProperty("nProductisHot")]
        public int NProductisHot
        {
            get { return (int)base["nProductisHot"]; }
            set { base["nProductisHot"] = value; }
        }
    }

    public class BranchElement : ConfigurationElement
    {
        [ConfigurationProperty("enableCaching", DefaultValue = "true")]
        public bool EnableCaching
        {
            get { return (bool)base["enableCaching"]; }
            set { base["enableCaching"] = value; }
        }

        [ConfigurationProperty("cacheDuration")]
        public int CacheDuration
        {
            get
            {
                return (int)base["cacheDuration"];
            }
            set { base["cacheDuration"] = value; }
        }
    }

    public class PageElement : ConfigurationElement
    {
        [ConfigurationProperty("enableCaching", DefaultValue = "true")]
        public bool EnableCaching
        {
            get { return (bool)base["enableCaching"]; }
            set { base["enableCaching"] = value; }
        }

        [ConfigurationProperty("cacheDuration")]
        public int CacheDuration
        {
            get
            {
                return (int)base["cacheDuration"];
            }
            set { base["cacheDuration"] = value; }
        }
    }

    public class SettingElement : ConfigurationElement
    {
        [ConfigurationProperty("enableCaching", DefaultValue = "true")]
        public bool EnableCaching
        {
            get { return (bool)base["enableCaching"]; }
            set { base["enableCaching"] = value; }
        }

        [ConfigurationProperty("cacheDuration")]
        public int CacheDuration
        {
            get
            {
                return (int)base["cacheDuration"];
            }
            set { base["cacheDuration"] = value; }
        }
    }

    public class MediaElement : ConfigurationElement
    {
        [ConfigurationProperty("enableCaching", DefaultValue = "true")]
        public bool EnableCaching
        {
            get { return (bool)base["enableCaching"]; }
            set { base["enableCaching"] = value; }
        }

        [ConfigurationProperty("cacheDuration")]
        public int CacheDuration
        {
            get
            {
                return (int)base["cacheDuration"];
            }
            set { base["cacheDuration"] = value; }
        }
    }

    public class FaqElement : ConfigurationElement
    {
        [ConfigurationProperty("enableCaching", DefaultValue = "true")]
        public bool EnableCaching
        {
            get { return (bool)base["enableCaching"]; }
            set { base["enableCaching"] = value; }
        }

        [ConfigurationProperty("cacheDuration")]
        public int CacheDuration
        {
            get
            {
                return (int)base["cacheDuration"];
            }
            set { base["cacheDuration"] = value; }
        }
    }
}
